package samples.spring.step2;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import samples.spring.step1.SpringAppStep1;
import samples.spring.step2.beans.LoginModel;

/**
 * spring bean的生命周期测试
 *
 * @author Zi Lai Ye
 * @date 2017/4/11
 */
public class SpringAppStep2 {
    public static final Logger LOGGER = LoggerFactory.getLogger(SpringAppStep1.class);

    public static void main(String[] args) {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:step2/step2.xml");
//        LOGGER.info("==============classpathxmlapplicationcontext create completed.");
//        User user = context.getBean(User.class);
//        LOGGER.info("=============={}", user);

        testPasswordPostProcessor(context);
//        context.registerShutdownHook();
    }

    private static void testPasswordPostProcessor(ApplicationContext context){
        LoginModel loginModel = context.getBean(LoginModel.class);
        LOGGER.info("password:{}", loginModel.getPassword());
    }
}
